﻿<%@ Page Title="" Language="C#" MasterPageFile="~/AuthoriztionMaster.master" AutoEventWireup="true"
    CodeBehind="quanlynguoidung.aspx.cs" Inherits="Giaiphongmatbang.quanlynguoidung" %>

<%@ Register Src="~/UserControl/ucPaging.ascx" TagName="ucPaging" TagPrefix="uc1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <link href="Style/duan.css" rel="stylesheet" type="text/css" />
    <link href="Style/skinstyle.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript">
        $(document).ready(function () {
            $('#chkHeader').click(function () {
                var isCheck = $(this).attr('checked');
                $('#<%=grvRole.ClientID %> input:checkbox').attr('checked', isCheck);
            });
        });
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="mainContent" runat="server">
    <div class="table">
        <asp:Panel ID="pn1" runat="server">
            <div class="box-title">
                Quản lý người dùng
                <div class="nr" style="margin-top: 3px">
                    <asp:ImageButton ID="btnAdd" runat="server" ImageUrl="~/Images/add-button.jpg" OnClick="btnAdd_Click" ToolTip="Thêm mới người dùng" />
                </div>
            </div>
            <fieldset class="boxsearch">
                <legend><strong>Tim kiếm</strong></legend>
                <p>
                    <span>Tên hiển thị:&nbsp;&nbsp;<asp:TextBox ID="txtDisplayNameSearch" runat="server"
                        CssClass="field"></asp:TextBox>&nbsp;&nbsp;</span> <span>Tên đầy đủ:&nbsp;&nbsp;<asp:TextBox
                            ID="txtFullNameSearch" runat="server" CssClass="field"></asp:TextBox>&nbsp;&nbsp;</span>
                    <asp:Button ID="btnSearch" runat="server" Text="Tìm kiếm" CssClass="button" OnClick="btnSearch_Click" />&nbsp;&nbsp;&nbsp;
                    <asp:Button ID="btnAll" runat="server" Text="Tất cả" CssClass="button" OnClick="btnAll_Click" />
                    <span style="float: right;">Trạng thái:&nbsp;&nbsp;
                        <asp:DropDownList ID="ddlStatus" runat="server" AutoPostBack="True" CssClass="field" OnSelectedIndexChanged="ddlStatus_SelectedIndexChanged">
                            <asp:ListItem Selected="True" Value="0">--Tât cả--</asp:ListItem>
                            <asp:ListItem Value="1">--Mở------</asp:ListItem>
                            <asp:ListItem Value="2">--Khóa----</asp:ListItem>
                        </asp:DropDownList>
                    </span>
                </p>
            </fieldset>
            <asp:GridView ID="grvUser" runat="server" AutoGenerateColumns="false" Width="100%"
                BorderWidth="0" GridLines="None" onrowcommand="grvUser_RowCommand">
                <Columns>
                    <asp:TemplateField HeaderText="TT" ItemStyle-Width="10px">
                        <ItemTemplate>
                            <%#Container.DataItemIndex + 1 %>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Tên hiển thị">
                        <ItemTemplate>
                            <asp:LinkButton ID="lbtnUser" runat="server" OnClick="lbtnUser_Click" CommandArgument='<%#Eval("UserID") %>'
                                ToolTip="Xem quyền của người này trong hệ thống"><%#Eval("DisplayName") %></asp:LinkButton>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:BoundField DataField="FullName" HeaderText="Tên đầy đủ" />
                    <asp:BoundField DataField="Address" HeaderText="Địa chỉ" />
                    <asp:BoundField DataField="PhoneNumber" HeaderText="Điện thoại" />
                    <asp:BoundField DataField="Email" HeaderText="Email" />
                    <asp:TemplateField HeaderText="Trạng thái" ItemStyle-Width="70px">
                        <ItemTemplate>
                            <%#Eval("isDisable").ToString()=="True"?"Khóa":"Mở" %>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Xóa" ItemStyle-Width="15px">
                        <ItemTemplate>
                            <asp:ImageButton ID="btnDelete" runat="server" ImageUrl="~/Images/delete.png" CommandArgument='<%#Eval("UserID") %>'
                                CommandName="btnDelete" OnClientClick="return confirm('Bạn chắc chắn xóa người dùng này?')"
                                ValidationGroup="1" />
                        </ItemTemplate>
                    </asp:TemplateField>
                </Columns>
            </asp:GridView>
            <div style="text-align: center;">
                <asp:Literal ID="ltrResult" runat="server"></asp:Literal></div>
        </asp:Panel>
        <asp:Panel ID="pn2" runat="server" Visible="false">
            <fieldset class="box-content">
                <legend><strong>Thông tin chi tiết</strong></legend>
                <div style="float: left; width: 500px;">
                    <p>
                        <span>Tên truy cập:</span>
                        <asp:TextBox ID="txtUserName" runat="server" CssClass="field" AutoComplete="Off"></asp:TextBox><i style="color:Red">(*)</i>
                        <span>
                            <asp:RequiredFieldValidator ID="rfv1" runat="server" ErrorMessage="(*)" ControlToValidate="txtUserName" ValidationGroup="1"></asp:RequiredFieldValidator>
                            <asp:RegularExpressionValidator ID="rev1" runat="server" ErrorMessage="" ValidationExpression="^[\S\s]{5,20}$"
                                ControlToValidate="txtUserName" ValidationGroup="1">Tối thiểu 6 ký tự</asp:RegularExpressionValidator></span>
                    </p>
                    <p>
                        <span>Tên đầy đủ:&nbsp;&nbsp;</span>
                        <asp:TextBox ID="txtFullName" runat="server" CssClass="field" AutoComplete="Off"></asp:TextBox><i style="color:Red">(*)</i></p>
                    <p>
                        <span>Tên hiển thị:&nbsp;</span>
                        <asp:TextBox ID="txtDisplayName" runat="server" CssClass="field" AutoComplete="Off"></asp:TextBox><i style="color:Red">(*)</i></p>
                    <p>
                        <span>Địa chỉ:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>
                        <asp:TextBox ID="txtAddress" runat="server" CssClass="field" AutoComplete="Off" AutoCompleteType="Disabled" ></asp:TextBox><i style="color:Red">(*)</i>
                        <asp:RequiredFieldValidator ID="rfv2" runat="server" ErrorMessage="(*)" ControlToValidate="txtAddress" ValidationGroup="1"></asp:RequiredFieldValidator></p>
                    <p>
                        <span>Mật khẩu:&nbsp;&nbsp;&nbsp;&nbsp</span>
                        <asp:TextBox ID="txtMatKhau" runat="server" TextMode="Password" CssClass="field"></asp:TextBox><i style="color:Red">(*)</i>
                        <asp:RequiredFieldValidator ID="rfv3" runat="server" ErrorMessage="(*)" ControlToValidate="txtMatKhau" ValidationGroup="1"></asp:RequiredFieldValidator>
                    </p>
                    <p>
                        <span>Nhập lại mật khẩu</span>
                        <asp:TextBox ID="txtRePassword" runat="server" TextMode="Password" CssClass="field" /><i style="color:Red">(*)</i>
                    </p>
                </div>
                <div style="float: left;">
                    <p>
                        <span>Điện thoại:&nbsp;&nbsp;</span>
                        <asp:TextBox ID="txtPhone" runat="server" CssClass="field" AutoComplete="Off"></asp:TextBox><i style="color:Red">(*)</i>
                        <asp:RegularExpressionValidator ID="rev3" runat="server" ErrorMessage="" ValidationExpression="[0-9+ -]{6,20}"
                            ControlToValidate="txtPhone" ValidationGroup="1">Điện thoại chưa đúng</asp:RegularExpressionValidator></p>
                    <p>
                        <span>Giới tính:&nbsp;&nbsp;&nbsp;&nbsp;</span>
                        <asp:DropDownList ID="ddlGender" runat="server" CssClass="field">
                            <asp:ListItem Value="true" Text="Nam"></asp:ListItem>
                            <asp:ListItem Value="false" Text="Nữ"></asp:ListItem>
                        </asp:DropDownList>
                    </p>
                    <p>
                        <span>Email:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>
                        <asp:TextBox ID="txtEmail" runat="server" CssClass="field" AutoComplete="Off"></asp:TextBox><i style="color:Red">(*)</i>
                        <asp:RegularExpressionValidator ID="rev4" runat="server" ErrorMessage="" ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"
                            ControlToValidate="txtEmail" ValidationGroup="1" >Email không hợp lệ</asp:RegularExpressionValidator>
                    </p>
                    <p>
                        <span>Người tạo:&nbsp;&nbsp;</span> <a href="#" title="Người tạo tài khoản này">
                            <asp:Literal ID="ltrCreateBy" runat="server"></asp:Literal></a></p>
                    <p>
                        <span>Trạng thái:&nbsp;&nbsp;&nbsp;&nbsp;</span>&nbsp;
                        <asp:CheckBox ID="chkStatus" runat="server" />&nbsp;(Khóa)
                    </p>
                </div>
            </fieldset>
            <fieldset class="box-content">
                <legend><strong>Các quyền trong hệ thống</strong></legend>
                <div style="margin-left: 285px; margin-top: 0px;">
                    <asp:GridView ID="grvRole" runat="server" AutoGenerateColumns="false" Width="60%"
                        OnRowDataBound="grvRole_RowDataBound" BorderWidth="0" GridLines="None">
                        <Columns>
                            <asp:TemplateField>
                                <HeaderTemplate>
                                    <input type="checkbox" id="chkHeader" />
                                </HeaderTemplate>
                                <ItemTemplate>
                                    <asp:CheckBox ID="chk" runat="server" />
                                    <asp:HiddenField ID="hdfRoleID" runat="server" Value='<%#Eval("RoleID") %>' />
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:BoundField DataField="RoleName" HeaderText="Quyền" />
                            <asp:BoundField DataField="Description" HeaderText="Mô tả" />
                        </Columns>
                    </asp:GridView>
                </div>
            </fieldset>
            <div class="box-content" style="text-align: center">
                <asp:Button ID="btnApply" CssClass="button" runat="server" Text="Áp dụng" OnClick="btnApply_Click" ValidationGroup="1" />&nbsp;
                <input type="reset" value="Làm  lại" class="button" />
                <asp:Button ID="btnReturn2" CssClass="button" runat="server" Text="Trở về" OnClick="btnReturn2_Click" ValidationGroup="0" />
            </div>
        </asp:Panel>
    </div>
</asp:Content>
